<template>
	<div id="handle-qq-login" class="ac">
		<div class="row" v-for="(item, index) in arr" :key="index">{{ formatTime(item.time) }}===>{{ item.msg }}</div>
	</div>
</template>

<script>
import isPE from '@/utils/isPE.js';
import config from '@/config/index.js'
import { autoLogin } from '@/api/user.js'
export default {
	created() {
		this.log("isPE", isPE())
		let token = this.$route.query.token
		this.log("token=" + token)
		if (token) {
			window.localStorage.setItem("authorization", token)
			autoLogin().then(res => {
				this.log("res.code="+res.code)
				if(res.code==200){
					this.$store.commit("user/setUser",res.data)
					let peRedirectPath=this.$route.query.peRedirectPath
					this.log("peRedirectPath",peRedirectPath)
					if(peRedirectPath){
						this.$router.push(peRedirectPath)
					}else{
						this.$router.push("/")
					}
				}
			})
		}
	},
	methods: {
		log(...str) {
			this.arr.push({
				time: new Date(),
				msg: JSON.stringify(str)
			})
		},
		formatTime(d) {
			return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()
		}
	},
	data() {
		return {
			arr: []
		};
	}
};
</script>

<style lang="scss">
#handle-qq-login {
	position: fixed;
	height: 100%;
	width: 100%;
	top: 0;
	left: 0;
	background-color: #fff;

	.row {
		display: block;
		text-align: left;
		word-break: break-all;
		padding: 10px;
		// justify-content: space-between;
	}
}
</style>
